<!DOCTYPE html><html lang="en"><head><title>PaymentExperienceGet.aspx</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="PaymentExperienceGet.aspx"><meta name="groc-project-path" content="PaymentExperienceGet.aspx.cs"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">PaymentExperienceGet.aspx.cs</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper">﻿<span class="hljs-keyword">using</span> System;
<span class="hljs-keyword">using</span> System.Collections;
<span class="hljs-keyword">using</span> System.Configuration;
<span class="hljs-keyword">using</span> System.Data;
<span class="hljs-keyword">using</span> System.Linq;
<span class="hljs-keyword">using</span> System.Web;
<span class="hljs-keyword">using</span> System.Web.Security;
<span class="hljs-keyword">using</span> System.Web.UI;
<span class="hljs-keyword">using</span> System.Web.UI.HtmlControls;
<span class="hljs-keyword">using</span> System.Web.UI.WebControls;
<span class="hljs-keyword">using</span> System.Web.UI.WebControls.WebParts;
<span class="hljs-keyword">using</span> System.Xml.Linq;
<span class="hljs-keyword">using</span> PayPal.Api;
<span class="hljs-keyword">using</span> Newtonsoft.Json.Linq;
<span class="hljs-keyword">using</span> Newtonsoft.Json;

namespace PayPal.Sample
{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">partial</span> <span class="hljs-keyword">class</span> PaymentExperienceGet : BaseSamplePage
    {
        <span class="hljs-keyword">protected</span> <span class="hljs-keyword">override</span> <span class="hljs-keyword">void</span> <span class="hljs-title">RunSample</span>()
        {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="api-context">Api Context</h3>
<p>Pass in a <code>APIContext</code> object to authenticate 
the call and to send a unique request id 
(that ensures idempotency). The SDK generates
a request id if you do not pass one explicitly. 
See <a href="/Source/Configuration.html">Configuration.cs</a> to know more about APIContext.</p></div></div><div class="code"><div class="wrapper">            <span class="hljs-keyword">var</span> apiContext = Configuration.GetAPIContext();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Setup the profile we want to create</p></div></div><div class="code"><div class="wrapper">            <span class="hljs-keyword">var</span> profile = <span class="hljs-keyword">new</span> WebProfile()
            {
                name = Guid.NewGuid().ToString(),
                presentation = <span class="hljs-keyword">new</span> Presentation()
                {
                    brand_name = <span class="hljs-string">"Sample brand"</span>,
                    locale_code = <span class="hljs-string">"US"</span>,
                    logo_image = <span class="hljs-string">"https://www.paypal.com/"</span>
                },
                input_fields = <span class="hljs-keyword">new</span> InputFields()
                {
                    address_override = <span class="hljs-number">1</span>,
                    allow_note = <span class="hljs-keyword">true</span>,
                    no_shipping = <span class="hljs-number">0</span>
                },
                flow_config = <span class="hljs-keyword">new</span> FlowConfig()
                {
                    bank_txn_pending_url = <span class="hljs-string">"https://www.paypal.com/"</span>,
                    landing_page_type = <span class="hljs-string">"billing"</span>
                }
            };

            <span class="hljs-preprocessor">#<span class="hljs-keyword">region</span> Track Workflow</span>
            <span class="hljs-comment">//--------------------</span>
            <span class="hljs-keyword">this</span>.flow.AddNewRequest(<span class="hljs-string">"Create profile"</span>, profile);
            <span class="hljs-comment">//--------------------</span>
            <span class="hljs-preprocessor">#<span class="hljs-keyword">endregion</span></span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create the profile</p></div></div><div class="code"><div class="wrapper">            <span class="hljs-keyword">var</span> response = profile.Create(apiContext);

            <span class="hljs-preprocessor">#<span class="hljs-keyword">region</span> Track Workflow</span>
            <span class="hljs-comment">//--------------------</span>
            <span class="hljs-keyword">this</span>.flow.RecordResponse(response);
            <span class="hljs-keyword">this</span>.flow.AddNewRequest(<span class="hljs-string">"Retrieve profile"</span>, description: <span class="hljs-string">"ID: "</span> + response.id);
            <span class="hljs-comment">//--------------------</span>
            <span class="hljs-preprocessor">#<span class="hljs-keyword">endregion</span></span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Get the profile using the ID returned from the previous Create() call.</p></div></div><div class="code"><div class="wrapper">            <span class="hljs-keyword">var</span> retrievedProfile = WebProfile.Get(apiContext, response.id);

            <span class="hljs-preprocessor">#<span class="hljs-keyword">region</span> Track Workflow</span>
            <span class="hljs-comment">//--------------------</span>
            <span class="hljs-keyword">this</span>.flow.RecordResponse(retrievedProfile);
            <span class="hljs-comment">//--------------------</span>
            <span class="hljs-preprocessor">#<span class="hljs-keyword">endregion</span></span>

            <span class="hljs-preprocessor">#<span class="hljs-keyword">region</span> Cleanup</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Cleanup by deleting the newly-created profile</p></div></div><div class="code"><div class="wrapper">            retrievedProfile.Delete(apiContext);
            <span class="hljs-preprocessor">#<span class="hljs-keyword">endregion</span></span>
        }
    }
}</div></div></div></div></body></html>